package com.itheima.sort;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class SortMapperTask extends Mapper<LongWritable,Text,SortPojo, NullWritable> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String line = value.toString();
        if(line!=null & !"".equals(line)){
            String first = line.split("\t")[0];
            String second = line.split("\t")[1];

            SortPojo sortPojo = new SortPojo();
            sortPojo.setFirst(first);
            sortPojo.setSecond(second);

            context.write(sortPojo,NullWritable.get());

        }
    }
}
